<?php
/**
 * Created by PhpStorm.
 * User: huangzikun
 * Date: 2018/4/19
 * Time: 17:06
 */
namespace Huangzikun\hawkeye_spider;

class MemSpiderClass extends BaseClass
{
    private $filePath = "/proc/meminfo";
    public $spiderInfo;
    public $apiAddress;

    public function __construct($apiAddress)
    {
        parent::__construct($apiAddress);
    }

    /**
     * cpu信息抓取
     */
    public function grab()
    {
        $info = file($this->filePath);
        if(!empty($info) && is_array($info)){
            foreach ($info as $str){
                $str = str_replace("\n", "", $str);
                $str = str_replace("kB", "", $str);
                $tmp = explode(":", $str);
                if(count($tmp) == 2){
                    $this->spiderInfo[trim($tmp[0])] = trim($tmp[1]);
                }
            }
        }
    }
}